// 本地存储相关
// @ts-ignore
import Cookies from 'js-cookie'

export const getCookies = (key: string): string | object => {
  return Cookies.get(key)
}

export const setCookies = (key: string, value: any): void => {
  Cookies.set(key, value, { expires: 1 }) // default expires time 1day
}

export const setSessionStorage = (key: string, val: string): void => {
  sessionStorage.setItem(key, val)
}

export const getSessionStorage = (key: string): string => {
  return sessionStorage.getItem(key) as string
}

export const cleanSessionStorage = (key: string) => {
  sessionStorage.removeItem(key)
}

export const cleanAllSessionStorage = () => {
  sessionStorage.clear()
}

export const removeCookies = (key: string): void => {
  Cookies.remove(key)
}
